package com.itheima.streamdemo;

public class ParamDemo1 {

    public static void main(String[] args) {
        // 可变参数
        System.out.println(sum(1, 2, 3, 4, 5));
        System.out.println(sum());
        System.out.println(sum(new int[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}));
    }

    public static int sum(int...nums){
        // 可变参数对内就是一个数组
        int sum = 0;
        for (int i : nums) {
            sum += i;
        }
        return sum;
    }
}
